package com.azure.bigstore.service;

import com.azure.bigstore.entity.Activity;
import com.azure.bigstore.repository.ActivityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by liuhuaibin on 2018/1/23.
 */
@Service
public class ActivityService {
    @Autowired
    private ActivityRepository activityRepository;

    public List<Activity> getActivities(){
        return activityRepository.findAll();
    }

    public Activity getActivity(String id){
        return activityRepository.findOne(Long.valueOf(id));
    }

    public Activity saveActivity(Activity activity){
        return activityRepository.save(activity);
    }

    public void deleteActivity(String id){
        activityRepository.delete(Long.valueOf(id));
    }
}
